<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/8/24 0024
  Time: 10:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% String path = request.getContextPath();%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<script src="<%=path%>/static/js/jquery-3.5.1.min.js"></script>
<style>
    table tr img{
        width: 50px;
        height: 50px;
    }
    table tr{
        text-align: center;
    }

</style>
<script>
    $(function () {
        $("a[class=link-del]").click(function () {
           var id = $(this).attr("id");
           $.get("<%=path%>/manage/comment/del",{id:id},function () {
                $(this).parent().parent().remove();
           }.bind(this));
           return false;
        });
    });
    $(function () {
        $(".allChoose").click(function () {
            $(":checkbox[id='choose']").prop("checked",$(this).prop("checked"));
        });
    });
</script>
<table class="result-tab" width="100%">
    <tr>
        <th class="tc" width="5%"><input class="allChoose" name="" type="checkbox"></th>
        <th>用户名</th>
        <th>性别</th>
        <th>头像</th>
        <th>职位名称</th>
        <th>评论内容</th>
        <th>评论时间</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${requestScope.commentPageInfo.list}" var="comment">
        <tr>
            <td class="tc"><input name="id[]" id="choose" value="${comment.id}" type="checkbox"></td>
            <td>${comment.userinfo.username}</td>
            <td>
                <c:if test="${comment.userinfo.sex eq null}">
                    保密
                </c:if>
                <c:if test="${comment.userinfo.sex ne null}">
                    ${comment.userinfo.sex}
                </c:if>
            </td>
            <td>
                <c:if test="${comment.userinfo.headImage eq null}">
                    <img src="<%=path%>/static/web/images/default_headpic.png">
                </c:if>
                <c:if test="${comment.userinfo.headImage ne null}">
                    <img src="<%=path%>/static/uploadImg/${comment.userinfo.headImage}">
                </c:if>
            </td>
            <td>${comment.job.name}</td>
            <td>${fn:substring(comment.content,0 ,10 )}${fn:length(comment.content)gt 10?'...':''}</td>
            <td><fmt:formatDate value="${comment.inputTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
            <td>
                <a class="link-update"  href="<%=path%>/manage/comment/reply?id=${comment.id}" id="${comment.id}">查看回复</a>
                <a class="link-del" href="#" id="${comment.id}">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
<div class="list-page">
    ${requestScope.commentPageInfo.pages}页
    <a href="#" data-pagenum="1">首页 </a>
    <c:if test="${requestScope.commentPageInfo.pageNum gt 1}">
        <a href="#" data-pagenum="${requestScope.commentPageInfo.pageNum-1}">上一页</a>
    </c:if>

    <c:forEach begin="1" end="${requestScope.commentPageInfo.pages}" var="i">

        <a href="#" data-pagenum="${i}"
                <c:if test="${i eq requestScope.commentPageInfo.pageNum}"> class="current" </c:if>>${i}</a>
    </c:forEach>

    <c:if test="${requestScope.commentPageInfo.pageNum lt requestScope.commentPageInfo.pages}">
        <a href="#" data-pagenum="${requestScope.commentPageInfo.pageNum+1}">下一页</a>
    </c:if>
    <a href="#" data-pagenum="${requestScope.commentPageInfo.pages}">尾页 </a>
    ${requestScope.commentPageInfo.pageNum}/${requestScope.commentPageInfo.pages}页
</div>

